import request from "@/utils/request";

// 查询项目文件夹列表
export function listProjectFolder2(query) {
  return request({
    url: "/production/companyNoticeFolder/list",
    method: "get",
    params: query,
  });
}

// 查询项目文件夹所有列表
export function listAllProjectFolder2(query) {
  return request({
    url: "/production/companyNoticeFolder/listAll",
    method: "get",
    params: query,
  });
}

// 查询项目文件夹详细
export function getProjectFolder2(id) {
  return request({
    url: "/production/companyNoticeFolder/getInfo/" + id,
    method: "get",
  });
}

// 新增项目文件夹
export function addProjectFolder2(data) {
  return request({
    url: "/production/companyNoticeFolder/add",
    method: "post",
    data: data,
  });
}

// 修改项目文件夹
export function updateProjectFolder2(data) {
  return request({
    url: "/production/companyNoticeFolder/edit",
    method: "post",
    data: data,
  });
}

// 删除项目文件夹
export function delProjectFolder2(id) {
  return request({
    url: "/production/companyNoticeFolder/remove/" + id,
    method: "get",
  });
}

// 查询项目文件信息列表
export function listProjectFileInfo2(query) {
  return request({
    url: "/production/companyNoticeFile/list",
    method: "get",
    params: query,
  });
}

// 查询项目文件信息所有列表
export function listAllProjectFileInfo2(query) {
  return request({
    url: "/production/companyNoticeFile/listAll",
    method: "get",
    params: query,
  });
}

// 查询项目文件信息详细
export function getProjectFileInfo2(id) {
  return request({
    url: "/production/companyNoticeFile/getInfo/" + id,
    method: "get",
  });
}

// 新增项目文件信息
export function addProjectFileInfo(data) {
  return request({
    url: "/production/companyNoticeFile/addByFile",
    method: "post",
    data: data,
  });
}

// 新增项目文件多文件上传接口
export function addProjectFileInfo2({
  files,
  folderId,
  fileType,
  projectId,
  menuCategory,
}) {
  const formData = new FormData();
  // 支持多文件
  files.forEach((file) => {
    formData.append("files", file);
  });
  formData.append("folderId", folderId);
  formData.append("fileType", fileType);
  formData.append("projectId", projectId);
  if (menuCategory !== undefined && menuCategory !== null) {
    formData.append("menuCategory", menuCategory);
  }
  return request({
    url: "/production/companyNoticeFile/addByFile",
    method: "post",
    data: formData,
    headers: {
      "X-Requested-With": "XMLHttpRequest",
      // 不要加Content-Type，axios会自动处理
    },
  });
}

// 修改项目文件信息
export function updateProjectFileInfo2(data) {
  return request({
    url: "/production/companyNoticeFile/edit",
    method: "post",
    data: data,
  });
}

// 删除项目文件信息
export function delProjectFileInfo2(id) {
  return request({
    url: "/production/companyNoticeFile/remove/" + id,
    method: "get",
  });
}
